package com.hendraanggrian.appcompat.widget;


/**
 * Simple optional mention data class, use when there is no custom mention class.
 */
public class Mention implements Mentionable {
    private final CharSequence username;
    private final CharSequence displayname;
    private final Object avatar;

    /**
     * 构造函数
     *
     * @param username 名称
     */
    public Mention(CharSequence username) {
        this(username, null);
    }

    /**
     * 构造函数
     *
     * @param username 名称
     * @param displayname 详情
     */
    public Mention(CharSequence username, CharSequence displayname) {
        this(username, displayname, null);
    }

    /**
     * 构造函数
     *
     * @param username 名称
     * @param displayname 详情
     * @param avatar 头像
     */
    public Mention(CharSequence username, CharSequence displayname, Object avatar) {
        this.username = username;
        this.displayname = displayname;
        this.avatar = avatar;
    }

    @Override
    public boolean equals(Object obj) {
        return obj instanceof Mention && ((Mention) obj).username == username;
    }

    @Override
    public int hashCode() {
        return username.hashCode();
    }

    @Override
    public String toString() {
        return username.toString();
    }

    @Override
    public CharSequence getUsername() {
        return username;
    }

    @Override
    public CharSequence getDisplayname() {
        return displayname;
    }

    @Override
    public Object getAvatar() {
        return avatar;
    }
}